#include "TCP_socket.hpp"

using namespace mycode;
int main(int argc, char* argv[])
{
    //./client ip port
    if (argc != 3)
    {
        LOG_INFO("use error");
        exit(USEERR);
    }
    string ip = argv[1];
    uint16_t port = static_cast<uint16_t>(atoi(argv[2]));

    //创建TCP对象
    TCP client(ip, port);

    //创建连接
    client.TCP_Connect();

    char buff[1024];
    while(true)
    {
        cout << "say: ";
        std::cin >> buff;
        int s = write(client.getSocket(), buff, sizeof(buff));
        if (s < 0)
        {
            perror("write");
            LOG_ERROR("client write error");
            exit(WRITEERR);
        }
    }

    return 0;
}